ASP.NET Core 6 Succinctly by Dirk Strauss
Author:Dirk Strauss
Language: eng
Format: epub, mobi
Tags: An introduction to ASP.NET Core 6 web development.
Publisher: Syncfusion, Inc.
Figure 47: The Weather Forecast in Chrome
I like using Postman to test my APIs, but you can also use your browser to make the GET request, as seen in Figure 47. Minimal APIs also have full Swagger support, as seen in Code Listing 27, higher up in the Program file.
Go back to your properties and click to modify the Launch Profile for IIS Express, as shown in Figure 48. Select the option Launch browser.
Figure 48: Select to Launch the Browser
Figure 49: Viewing Your API in Swagger
Running your API again, you will see the browser launch and the Swagger page displayed for your weather forecast API. Under the MinAPI name at the top of our page, click the link https://localhost:44349/swagger/v1/swagger.json to view the Swagger JSON file. This file is shown in Code Listing 28.
The file displays the details of the minimal API based on the OpenAPI specification. You can see the details we set in the WithName method in Code Listing 27 show up in the operationId in the Swagger JSON file in Code Listing 28.
Other extension methods, such as WithTags, are available for use in your API to add metadata, so have a look at what there is on offer.
Code Listing 28: The Swagger JSON File
{
"openapi": "3.0.1",
"info": {
"title": "MinAPI",
"version": "1.0"
},
"paths": {
"/weatherforecast": {
"get": {
"tags": [
"MinAPI"
],
"operationId": "GetWeatherForecast",
"responses": {
"200": {
"description": "Success",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/WeatherForecast"
}
}
}
}
}
}
}
}
},
"components": {
"schemas": {
"WeatherForecast": {
"type": "object",
"properties": {
"date": {
"type": "string",
"format": "date-time"
},
"temperatureC": {
"type": "integer",
"format": "int32"
},
"summary": {
"type": "string",
"nullable": true
},
"temperatureF": {
"type": "integer",
"format": "int32",
"readOnly": true
}
},
"additionalProperties": false
}
}
}
}
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Deep Learning with Python by François Chollet(11922)
Hello! Python by Anthony Briggs(9385)
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(9352)
The Mikado Method by Ola Ellnestam Daniel Brolund(9321)
Dependency Injection in .NET by Mark Seemann(8866)
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(7859)
Test-Driven iOS Development with Swift 4 by Dominik Hauser(7348)
Grails in Action by Glen Smith Peter Ledbrook(7304)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(7124)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(5968)
Kotlin in Action by Dmitry Jemerov(4653)
Practical Vim (for Kathryn Amaral) by Drew Neil(3732)
Cracking the GRE Premium Edition with 6 Practice Tests, 2015 (Graduate School Test Preparation) by Princeton Review(3600)
Linux Device Driver Development Cookbook by Rodolfo Giometti(3447)
Learn Windows PowerShell in a Month of Lunches by Don Jones(3252)
Learning Java by Patrick Niemeyer & Daniel Leuck(2873)
Learning React: Functional Web Development with React and Redux by Banks Alex & Porcello Eve(2844)
Becoming a Dynamics 365 Finance and Supply Chain Solution Architect by Brent Dawson(2834)
Microservices with Go by Alexander Shuiskov(2624)